<?php 
class Item_Model extends Model{
	
	public function __construct(){
		$this->_dbName = Dbtool::getDBName('main');
		$this->_table = 'comm_items';
		parent::__construct($this);
	}
	
	
	/**
	 * 获取分享评论的所有项
	 * @param int $comid 评论ID
	 * @return
	 */
	public function getAllByComId($comid){
		return $this->where(array('comid'=>$comid))->getAll();
	}
	
	/**
	 * 创建评论的具体项
	 * @param int $comid 评论ID
	 * @param array $data 项资料数组
	 * @return
	 */
	public function create($comid,Array $data){
		$mod_comment = M('comment.comment');
		//分享的评论是否存在
		if ($mod_comment->getById($comid)){
			for ($i=0;$i<count($data);$i++){
				$tep = $data[$i];
				$tep['comid']=$comid;
				$this->insert($tep);
			}
		}
		return true;
	}
	
	
	/**
	 * 删除评论项
	 * @param array $comids 数组
	 * @return bool
	 */
	public function del(Array $comids){
		return $this->in('comid',$comids)->remove();
	}
}
?>